# -*- coding: utf-8 -*-

import os
basedir = os.path.abspath(os.path.dirname(__file__))


class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'lkasdh23487^$%%^23KJKJ'
    SQLALCHEMY_COMMIT_ON_TRARDOWN = True
    FLASK_MAIL_SUBJECT_PREFIX = '[JobHunter]'
    FLASK_MAIL_SENDER = 'Job Hunter Admin <admin@xxx.com>'
    FLASK_ADMIN = os.environ.get('FLASK_ADMIN')
    CELERY_BROKER_URL = 'amqp://jobrabbit:jobrabbit@localhost:5672//'

    @staticmethod
    def init_app(app):
        pass


class DevelopmentConfig(Config):
    DEBUG = True
    MAIL_SERVER = 'smtp.163.com'
    MAIL_PORT = 587
    MAIL_USE_TLS = True
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    SQLALCHEMY_DATABASE_URI = 'mysql://jobh:jobhadmin@localhost/jobHunter'
    CELERY_RESULT_BACKEND = 'db+'+SQLALCHEMY_DATABASE_URI
    # WHOOSH_BASE = SQLALCHEMY_DATABASE_URI
    USERS_PER_PAGE = 10
    JOBS_PER_PAGE = 10
    SCRAPYD_HOST = 'localhost'
    SCRAPYD_PORT = 6024


class ProductionConfig(Config):
    SQLALCHEMY_DATABASE_URI = 'mysql://jobh:jobhadmin@localhost/jobHunter'
    CELERY_RESULT_BACKEND = 'db+'+SQLALCHEMY_DATABASE_URI
    # WHOOSH_BASE = SQLALCHEMY_DATABASE_URI
    USERS_PER_PAGE = 20
    JOBS_PER_PAGE = 20
    SCRAPYD_HOST = 'localhost'
    SCRAPYD_PORT = 6024

config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig,
}